import httpInstance from "@/utils/http";


// 卖家登录接口
export function sellerLoginAPI({ username, password }) {
  return httpInstance({
    url: '/seller/login',
    method: 'POST',
    params: {
      username,
      password
    }
  })
}
// 卖家注册接口
export const sellerRegisterAPI = ({ username, password }) => {
  return httpInstance({
      url: '/seller/register',
      method: 'post',
      params: {
          username,
          password
      }
  })
}


//卖家获取自己的分类列表
export function sellerGetCategoryAPI() {
  return httpInstance({
    url: '/category/sellerGetCategory',
  })
}

//卖家获取自己的商品列表
export function sellerGetGoodsAPI(params) {
  return httpInstance({
    url: '/goods/sellerGetGoods',
    params
  })
}

//卖家创建商品
export function createGoodsAPI(data) {
  return httpInstance({
    url: '/goods/createGoods',
    method: 'POST',
    data
  })
}

//卖家商品上架and下架
export function stateChangeAPI(state, goodsId) {
  return httpInstance({
    url: '/goods/stateChange',
    params: {
      state: state,
      goodsId: goodsId
    }
  })
}
//卖家删除商品
export function deleteGoodsAPI(goodsId) {
  return httpInstance({
    url: '/goods/deleteGoods',
    params: {
      goodsId: goodsId
    }
  })
}
//卖家获取详细商品数据
export function getDetailGoodsAPI(id){
  return httpInstance({
    url:'/goods/sellerDetailGoods',
    params:{
      id
    }
  })
}
//卖家编辑商品
export function UpdateGoodsAPI(data) {
  return httpInstance({
    url: '/goods/updateGoods',
    method: 'POST',
    data
  })
}

//卖家获取详细订单数据
export function sellerGetOrderAPI(params){
  return httpInstance({
    url:'/order/sellerOrder',
    params
  })
}
//发货
export function sendGoodsAPI(id){
  return httpInstance({
    url:'/order/sendGoods',
    params:{
      id
    }
  })
}
//修改用户信息
export function useUpdateSellerAPI(data) {
  return httpInstance({
      url: '/seller/update',
      method: 'PUT',
      data
  })
}

//获取新的用户信息
export function newSellerInfoAPI() {
  return httpInstance({
      url: '/seller/sellerInfo'
  })
}

//修改用户头像
export function useUpdateAvatarAPI(avatarUrl) {
  return httpInstance({
      url: '/seller/updateAvatar',
      method: 'Patch',
      params: {
          avatarUrl
      }
  })
}

//修改用户密码
export function updatePasswordAPI(data) {
  return httpInstance({
      url: '/seller/updatePwd',
      method: 'Patch',
      data
  })
}





